package com.xiaohong.search.service;

import com.xiaohong.search.pojo.SkuInfo;
import org.elasticsearch.action.delete.DeleteResponse;
import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.action.update.UpdateResponse;

import java.io.IOException;
import java.util.Map;

public interface SearchSpuService {
    /**
     * 重新导入数据
     * @throws IOException
     */
    void reImportData() throws IOException;

    /**
     * 导入数据到索引库中
     */
    void importData() throws IOException;

    /**
     * 删除索引
     */
    void deleteIndex() throws IOException;

    /**
     * 判断索引是否存在
     * @return
     */
    Boolean isIndexExists() throws IOException;

    /**
     * 添加单条文档记录
     * @param skuInfo
     * @throws IOException
     * @return
     */
    IndexResponse addOneDocument(SkuInfo skuInfo) throws IOException;

    /**
     * 获取单条文档
     * @param id
     * @return
     * @throws IOException
     */
    String getDocument(String id) throws IOException;

    /**
     * 更新文档记录
     * @param id
     * @param skuInfo
     * @return
     * @throws IOException
     */
    UpdateResponse updateDocument(String id, SkuInfo skuInfo) throws IOException;

    /**
     * 删除文档记录
     * @param id
     * @return
     * @throws IOException
     */
    DeleteResponse deleteDocument(String id) throws IOException;

    /**
     * 多条件搜索（代码优化后最终结果）
     * @param searchMap
     * @return
     */
    Map<String,Object> search(Map<String, String> searchMap) throws IOException;

}
